package com.ddd.domain.model.sales;

import com.ddd.domain.share.ValueObject;
import org.springframework.util.StringUtils;

import java.time.LocalDate;

public class SalesProductValueObject implements ValueObject {


    /**
     * 商品id
     */
    private  String skuId;
    /**
     * 通用名
     */
    private  String commonName;
    /**
     * 批号
     */
    private  String batchNo;
    /**
     * 生产日期
     */
    private  LocalDate productionDate;

    /**
     * 有效期至
     */
    private  LocalDate expiryDate;
    /**
     * 销售数量
     */
    private int num;
    /**
     * 分
     */
    private long price;

    /**
     * @param skuId
     * @param commonName
     * @param batchNo
     * @param productionDate
     * @param expiryDate
     */
    public SalesProductValueObject(String skuId, String commonName, String batchNo, LocalDate productionDate, LocalDate expiryDate,int num,long price) {
        //todo 需要校验多个值
        if (StringUtils.isEmpty(skuId)){
            throw new RuntimeException("");
        }
        if (StringUtils.isEmpty(num)){
            throw new RuntimeException("销售数量不能为空");
        }
        this.skuId = skuId;
        this.commonName = commonName;
        this.batchNo = batchNo;
        this.productionDate = productionDate;
        this.expiryDate = expiryDate;
        this.num = num;
        this.price = price * num;
    }



    @Override
    public boolean sameValueAs(Object other) {
        return true;
    }
}
